﻿using AutoMapper;
using socialnetworkApp.Domain.Dto.Input;
using socialnetworkApp.Domain.Dto.Output;
using socialnetworkApp.Domain.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace socialnetworkApp.Domain
{
    public class AdminMapperProfile : Profile
    {
        public AdminMapperProfile() {
            CreateMap<Users, Record>()
                .ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.Username))
                .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(src => src.CreatedAt))
                .ForMember(dest => dest.UpdateTime, opt => opt.MapFrom(src => src.UpdateTime))
                .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Nickname))
                .ForMember(dest => dest.Phone, opt => opt.MapFrom(src => src.Phone))
                .ForMember(dest => dest.Password, opt => opt.MapFrom(src => src.Password))
                .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id));

            CreateMap<Role, RoleDto>();
            CreateMap<Permission, AddPermissionDto>()
                .ForMember(dest => dest.Pid, opt => opt.MapFrom(src => src.Pid))
                .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
                .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name))
                 .ForMember(dest => dest.Code, opt => opt.MapFrom(src => src.Code))
                 .ForMember(dest => dest.Level, opt => opt.MapFrom(src => src.Level));
                
            CreateMap<Permission, GetPermissionInfoOutput>()
                .ForMember(dest=>dest.Select,opt=>opt.MapFrom(src=>src.Select));
        }

    }
}
